﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Text;
using DapperExtensions;
using DapperExtensions.Mapper;
using DapperExtensions.Sql;
using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;

namespace MaximServices.Data
{
    public class DataBaseRepository
    {
        internal Database Database { get; }

        static DataBaseRepository()
        {
        }

        public DataBaseRepository(IOptions<ConnectionStringList> connectionStrings)
        {
            var config = new DapperExtensionsConfiguration(typeof(ClassMapper<>), new List<Assembly>(), new MySqlDialect());

            var sqlGenerator = new SqlGeneratorImpl(config);

            var connection = new MySqlConnection(connectionStrings.Value.ConnectionString1);

            Database = new Database(connection, sqlGenerator);
        }
    }
}
